﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using AFT.Parking.WebSite.Filter;
using Model = AFT.Parking.Entity;
using AFT.Parking.Foundation.Extensions;
using AFT.Parking.Bizlogic.Parkings;
using System.Linq.Expressions;
using AFT.Parking.Entity.ArgumentEntity;

namespace AFT.Parking.WebSite.Controllers
{
    [AdminOnly]
    public class CarController : BaseController
    {
        private readonly CarLocationBiz _carLocationBiz;
        public CarController()
        {
            _carLocationBiz = new CarLocationBiz();
        }
        //
        // GET: /Car/
        public ActionResult CarLocations(bool status = false, int page = 1)
        {
            Expression<Func<Model.CarLocation, bool>> exp = u => true;
            if (status)
                exp = exp.And(u => u.Status == 1);
            var p = new PaginationParam<Model.CarLocation>()
            {
                Expression = exp,
                PageSize = 20,
                PageIndex = page,
                OrderByList = new List<OrderBy<Model.CarLocation>>()
                 {
                      new OrderBy<Model.CarLocation>(){ Sort=false, exp= u=>u.CreatedOn}
                 }
            };
            return View(_carLocationBiz.GetCarLocations(p));
        }
        public ActionResult CarLocationRecords(int page = 1)
        {
            var p = new PaginationParam<Model.CarLocationRecord>()
            {
                Expression = u => true,
                PageSize = 20,
                PageIndex = page,
                OrderByList = new List<OrderBy<Model.CarLocationRecord>>()
                 {
                      new OrderBy<Model.CarLocationRecord>{ Sort=false, exp= u=>u.CreatedOn}
                 }
            };
            return View(_carLocationBiz.GetCarLocationRecords(p));
        }

        public ActionResult ParkingLocationRecords(string name, int page = 1)
        {

            return View();
        }
    }
}